﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using BackupAssurance.Library.ModelsDB;
using System.Data.SqlTypes;

namespace BackupAssurance.expDB.EF
{
    public class MainContextInitializer : CreateDatabaseIfNotExists<MainContext>
    {
        protected override void Seed(MainContext context)
        {
            loaddata(context);
        }

        private void loaddata(MainContext context)
        {
            DateTime minvalue = DateTime.MinValue.AddYears(2000);
            string _ComputerName = System.Environment.MachineName;
            //-----------------------------------------------------------------------------------------------------------------------------------
            /*            
                        var JobActionStandardRun0 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "BackupAssurance DB Refresh Job", description = "Forces the BackupAssurance service to restart every 90 minutes; reloading all its data from the database", DateOfMonth = 0, EveryHowMany = 90, DayOfWeek = 0, ScheduleHour = DateTime.Parse("00:00:00"), TypeSchedule = "SCH_BYMINUTE", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
                        var JobActionStandardRun1 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 0, name = "Delete Backups older than 90 days", description = "Runs Daily and attempts to deletes Backup files from the Archive(192.168.0.2) server  that are older than 90 days", DateOfMonth = 0, EveryHowMany = 90, DayOfWeek = 0, ScheduleHour = DateTime.Parse("03:00 am"), TypeSchedule = "SCH_DAILY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
                        var JobActionStandardRun2 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 0, name = "Verify Daily Backups", description = "Runs Daily and ensures that the backups took place the day before", DateOfMonth = 0, EveryHowMany = 1, DayOfWeek = 0, ScheduleHour = DateTime.Parse("02:30 am"), TypeSchedule = "SCH_DAILY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
                        var JobActionStandardRun3 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 0, name = "Verify Weekly Backups", description = "Runs Daily and ensures that the backups took place the day before", DateOfMonth = 0, EveryHowMany = 1, DayOfWeek = 6, ScheduleHour = DateTime.Parse("02:00 am"), TypeSchedule = "SCH_WEEKLY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
                        var JobActionStandardRun4 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 0, name = "SynchFiles", description = "Backs up the Application Attachments", DateOfMonth = 0, EveryHowMany = 5, DayOfWeek = 0, ScheduleHour = DateTime.Parse("01:00 am"), TypeSchedule = "SCH_DAILY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
                        var JobActionStandardRun5 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 0, name = "Run File", description = "Runs a file on a concurrent schedule", DateOfMonth = 0, EveryHowMany = 5, DayOfWeek = 0, ScheduleHour = DateTime.Parse("01:30 am"), TypeSchedule = "SCH_DAILY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
            */

            var JobActionStandardRun0 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "weekly at 5:00pm mon, tue,wed ", description = "", DateOfMonth = 0, EveryHowMany = 0, ScheduleHour = DateTime.Parse("05:00 pm"), TypeSchedule = "SCH_WEEKLY", dayMonday = true, dayTuesday = true, dayWednesday = true, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };

            var JobActionStandardRun1 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "hourly, 2hrs, 7 days          ", description = "", DateOfMonth = 0, EveryHowMany = 2, ScheduleHour = DateTime.Parse("00:00:00"), TypeSchedule = "SCH_HOURLY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
            var JobActionStandardRun2 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "hourly, 2hrs, mon,tue,wed     ", description = "", DateOfMonth = 0, EveryHowMany = 2, ScheduleHour = DateTime.Parse("00:00:00"), TypeSchedule = "SCH_HOURLY", dayMonday = true, dayTuesday = true, dayWednesday = true, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };

            var JobActionStandardRun3 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "daily, at 5:00pm  7 days      ", description = "", DateOfMonth = 0, EveryHowMany = 0, ScheduleHour = DateTime.Parse("05:00 pm"), TypeSchedule = "SCH_DAILY", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };

            var JobActionStandardRun4 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "monthly day23 5:00pm          ", description = "", DateOfMonth = 23, EveryHowMany = 0, ScheduleHour = DateTime.Parse("05:00 pm"), TypeSchedule = "SCH_MONTHLYONDATE", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };

            var JobActionStandardRun5 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "minute, 2mins 7 days          ", description = "", DateOfMonth = 0, EveryHowMany = 2, ScheduleHour = DateTime.Parse("00:00:00"), TypeSchedule = "SCH_BYMINUTE", dayMonday = false, dayTuesday = false, dayWednesday = false, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };
            var JobActionStandardRun6 = new pcJobAction { ServerName = _ComputerName, ServerIP = "", JobEnabled = 1, name = "minute, 2mins mon,tue,wed     ", description = "", DateOfMonth = 0, EveryHowMany = 2, ScheduleHour = DateTime.Parse("00:00:00"), TypeSchedule = "SCH_BYMINUTE", dayMonday = true, dayTuesday = true, dayWednesday = true, dayThursday = false, dayFriday = false, daySaturday = false, daySunday = false, DateCreated = DateTime.Now, RunNow = false, LastUpdated = minvalue, StartDate = DateTime.Now, EndDate = DateTime.MaxValue, RunTimeLast = minvalue, RunTimeNext = minvalue };


            context.JobActions.Add(JobActionStandardRun0);
            context.JobActions.Add(JobActionStandardRun1);
            context.JobActions.Add(JobActionStandardRun2);
            context.JobActions.Add(JobActionStandardRun3);
            context.JobActions.Add(JobActionStandardRun4);
            context.JobActions.Add(JobActionStandardRun5);
            context.JobActions.Add(JobActionStandardRun6);
            context.SaveChanges();

            var PlugInValue0 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "Refresh", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun0.Id, name = "Refresh", description = "", PlugInText = "<resource key=\"Default\">Default</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            var PlugInValue1 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun1.Id, name = "Map Network Drive", description = "Maps a Drive to the Archive Server", PlugInText = "<resource key=\"Action\">Map</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource><resource key=\"PromptForCredentials\">False</resource><resource key=\"ShareName\">\\\\192.168.0.2\\LocalAppData</resource><resource key=\"SaveCredentials\">False</resource><resource key=\"Login\">Domain\\app3administrator</resource><resource key=\"Password\">PasswordHere</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue2 = new pcPlugInValue { SendEmailWithResults = 1, DemoMode = 1, TypePlugIn = "DeleteOldFiles", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 1, pcJobActionId = JobActionStandardRun1.Id, name = "Delete Files", description = "Deletes Backup files from the Archive(192.168.0.2) server that are older than 90 days", PlugInText = "<resource key=\"DeleteEmptyFolders\">True</resource><resource key=\"ProcessFolder\">m:\\</resource><resource key=\"NumDaysDeleteBack\">90</resource><resource key=\"RecurseFolder\">True</resource><resource key=\"IncludeFilenames\"></resource><resource key=\"IncludeFolders\"></resource><resource key=\"IncludeExtensions\">bak;trn;dif;zip;log</resource><resource key=\"ExcludeFilenames\"></resource><resource key=\"ExcludeFolders\">*attachments*</resource><resource key=\"ExcludeExtensions\">bkf;mdf;ldf</resource> ", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue3 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILCONTINUE", ExecuteOrder = 2, pcJobActionId = JobActionStandardRun1.Id, name = "Unmap Network Drive", description = "", PlugInText = "<resource key=\"Action\">UnMap</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            var PlugInValue4 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun2.Id, name = "Map Network Drive", description = "Maps a Drive to the Archive Server", PlugInText = "<resource key=\"Action\">Map</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource><resource key=\"PromptForCredentials\">False</resource><resource key=\"ShareName\">\\\\192.168.0.2\\LocalAppData</resource><resource key=\"SaveCredentials\">False</resource><resource key=\"Login\">Domain\\app3administrator</resource><resource key=\"Password\">PasswordHere</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue5 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "VerifyFileExists", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 1, pcJobActionId = JobActionStandardRun2.Id, name = "Verify Daily Backup Files", description = "", PlugInText = "<resource key=\"PROCESSFOLDER\">m:\\</resource><resource key=\"NUMHOURSBACK\">30</resource><resource key=\"INCLUDEPATHSNFILENAMES\">*app2\\daily*|*app2_backup*|bak;*app3db\\daily\\app4*|*app4_backup*|dif;*app3db\\daily\\app3*|*app3_backup*|dif;*app3db\\daily\\performance*|*performance_backup*|DIF;*app3db\\daily\\portal*|*portal_backup*|DIF;*app5\\daily*|*app5*|TRN;*svn\\tmp*|*app6*|zip;*svn\\tmp*|*cod-*|zip;*svn\\tmp*|*app7*|zip;*svn\\tmp*|*app3-*|zip;*svn\\tmp*|*app8*|zip;*svn\\tmp*|*app9*|zip;*Application\\daily\\bak*|Application Daily|BAK</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue6 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILCONTINUE", ExecuteOrder = 2, pcJobActionId = JobActionStandardRun2.Id, name = "Unmap Network Drive", description = "", PlugInText = "<resource key=\"Action\">UnMap</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            var PlugInValue7 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun3.Id, name = "Map Network Drive", description = "Maps a Drive to the Archive Server", PlugInText = "<resource key=\"Action\">Map</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource><resource key=\"PromptForCredentials\">False</resource><resource key=\"ShareName\">\\\\192.168.0.2\\LocalAppData</resource><resource key=\"SaveCredentials\">False</resource><resource key=\"Login\">Domain\\app3administrator</resource><resource key=\"Password\">PasswordHere</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue8 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "VerifyFileExists", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 1, pcJobActionId = JobActionStandardRun3.Id, name = "Verify Weekly Backup Files", description = "", PlugInText = "<resource key=\"PROCESSFOLDER\">m:\\</resource><resource key=\"NUMHOURSBACK\">30</resource><resource key=\"INCLUDEPATHSNFILENAMES\">*app2\\weekly*|*app2_backup*|bak;*app3db\\weekly*|*app2_backup*|bak;*app3db\\weekly\\app4*|*app4_backup*|dif;*app3db\\weekly\\app3*|*app3_backup*|dif;*app3db\\weekly\\performance*|*performance_backup*|DIF;*app3db\\weekly\\portal*|*portal_backup*|DIF;*app5\\weekly*|*app5*|TRN;*Application\\weekly\\bak*|Application weekly|BAK</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };
            var PlugInValue9 = new pcPlugInValue { SendEmailWithResults = 0, DemoMode = 0, TypePlugIn = "MountDrive", Runversion = 1, TypeOnFailure = "JOBFAILCONTINUE", ExecuteOrder = 2, pcJobActionId = JobActionStandardRun3.Id, name = "Unmap Network Drive", description = "", PlugInText = "<resource key=\"Action\">UnMap</resource><resource key=\"Force\">True</resource><resource key=\"Persistent\">True</resource><resource key=\"LocalDrive\">m:</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            var PlugInValue10 = new pcPlugInValue { SendEmailWithResults = 1, DemoMode = 1, TypePlugIn = "FileCopyMove", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun4.Id, name = "Backup Application Attachments", description = "Backup Application Attachments", PlugInText = "<resource key=\"ProcessFolder\">C:\\code\\MEF2_Preview3</resource><resource key=\"TargetFolder\">c:\\temp\\_test</resource><resource key=\"NumHoursBack\">24</resource><resource key=\"OverrideFile\">True</resource><resource key=\"MoveFileFlag\">False</resource><resource key=\"CompareEachFile\">False</resource><resource key=\"UseHourSystem\">False</resource><resource key=\"RecurseFolder\">True</resource><resource key=\"IncludeFilenames\"></resource><resource key=\"IncludeFolders\"></resource><resource key=\"IncludeExtensions\"></resource><resource key=\"ExcludeFilenames\"></resource><resource key=\"ExcludeFolders\"></resource><resource key=\"ExcludeExtensions\">pdb</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            var PlugInValue11 = new pcPlugInValue { SendEmailWithResults = 1, DemoMode = 1, TypePlugIn = "FileRun", Runversion = 1, TypeOnFailure = "JOBFAILSTOP", ExecuteOrder = 0, pcJobActionId = JobActionStandardRun5.Id, name = "Run Notepad.exe", description = "Run Notepad.exe", PlugInText = "<resource key=\"ProgramDirectory\">C:\\Windows</resource><resource key=\"CaptureOutput\">true</resource><resource key=\"ProgramParameters\">C:\\Data\\changesummary.txt</resource><resource key=\"ProgramName\">notepad.exe</resource>", DateCreated = DateTime.Now, LastUpdated = minvalue };

            context.PlugIns.Add(PlugInValue0);
            context.PlugIns.Add(PlugInValue1);
            context.PlugIns.Add(PlugInValue2);
            context.PlugIns.Add(PlugInValue3);
            context.PlugIns.Add(PlugInValue4);
            context.PlugIns.Add(PlugInValue5);
            context.PlugIns.Add(PlugInValue6);
            context.PlugIns.Add(PlugInValue7);
            context.PlugIns.Add(PlugInValue8);
            context.PlugIns.Add(PlugInValue9);
            context.PlugIns.Add(PlugInValue10);
            context.PlugIns.Add(PlugInValue11);

            context.SaveChanges();


            //-----------------------------------------------------------------------------------------------------------------------------------

            var JobAudit = new pcAuditLog { DateCreated = DateTime.Now, DateActualRun = DateTime.Now, name = "Database Created", description = "Initial entry into the audit log table.", ErrorTypeId = 0, Result = "Normal.", pcJobActionId = JobActionStandardRun0.Id };
            context.Audits.Add(JobAudit);
            context.SaveChanges();

        }


    }
}
